/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-25
 * Time: 16:33
 */
public class demo1 {
    static class Count {
        int count=0;
        public void increase() {
            count++;
        }
    }
    public static void main(String[] args) throws InterruptedException {
        Count count = new Count();
        Object o1 = new Object();
        Thread t1 = new Thread() {
            @Override
            public void run() {
                synchronized (o1) {
                    int i=10000;
                    while(i>0) {
                        count.increase();
                        i--;
                    }
                }
            }
        };
        Thread t2 = new Thread() {
            @Override
            public void run() {
                synchronized (Count.class) {
                    int i=10000;
                    while(i>0) {
                        count.increase();
                        i--;
                    }
                }
            }
        };
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(count.count);
    }
}
